Many data processing devices (e.g., mobile phone, electronic tables) are equipped with a limited amount of Random Access Memory (RAM), which fills as a user of the device launches applications. When an application is launched, one or more processes are started. A process is an instance of a software program that is sequentially executed by one or more processors of the device. A process can run concurrently with other processes on the device.
A memory management system dynamically allocates portions of memory to processes at their request and frees memory for reuse when no longer needed. For example, a virtual memory management system on a device can separate memory addresses used by a process from actual physical memory addresses, allowing separation of processes to effectively increase the available amount of RAM using paging or swapping to secondary storage.
When faced with a low memory condition, some memory management systems record a priority level for each process executing on the device and automatically terminate the lowest priority processes to free up memory without user intervention. The priority level is recorded prior to the low memory condition, when the process starts. Low priority processes are less likely to be used by user applications, and so their memory can be reclaimed for use by other, higher priority processes. The lowest priority processes are generally the least recently launched applications. The highest priority processes are generally the most recently launched applications and critical system processes.
As higher priority processes make use of more memory, processes are terminated in sequence gradually according to a priority scheme. If this termination process continues, user applications may be terminated. Terminating a user application affects the user's experience with a device due to the delay incurred in re-launching the terminated user application. One solution to this problem is to notify high priority processes ahead of their termination that the memory management system is facing memory pressure, so that the processes can release memory containing non-essential data. This can potentially free memory and let running processes co-exist without any further action. A crucial part of this procedure, however, is to identify when the memory management system is really under memory pressure. Since memory may be “full” with many low priority processes that are infrequently run, those low priority processes can be terminated without significant impact on the user experience. On the other hand, asking higher priority applications to free memory can have a negative performance affect, especially for multi-tasking environments where a user may be running two or more applications concurrently.